﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Wq.Application;
using Wq.Framework.Base.Admin;
using Wq.ManagerService.Entities;
using Wq.ManagerService.Models;
using Wq.ManagerService.Models.Region;
using Wq.MeetingService.Models;
using Wq.Model;


namespace Wq.Manager.API
{
    /// <summary>
    /// 开通的城市
    /// </summary>
    [Route("admin/opencity")]
    public class OpenCityController : ManagerBaseController
    {
        private readonly OpenCityApplication  application;
        /// <summary>
        /// 开通的城市
        /// </summary>
        public OpenCityController(OpenCityApplication application)
        {
            this.application = application;
        }

        /// <summary>
        /// 创建
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public IActionResult Insert(OpenCityInfo model)
        {
            application.Create(model);
            return SuccessResult();
        }

        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>

        [HttpPut("{regionId}")]
        public IActionResult Update(OpenCityInfo model)
        {
            application.Save(model);
            return SuccessResult();
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="regionId"></param>
        /// <returns></returns>
        [HttpDelete("{regionId}")]
        public IActionResult Delete(int regionId)
        {
            application.Delete(regionId);
            return SuccessResult();
        }

        /// <summary>
        /// 获取i详情
        /// </summary>
        /// <param name="regionId"></param>
        /// <returns></returns>
        [HttpGet("{regionId}")]
        public IActionResult Details(int regionId) => SuccessResult(application.Details(regionId));

        /// <summary>
        /// 修改会议室排序
        /// </summary>
        /// <param name="regionId"></param>
        /// <param name="sequence"></param>
        /// <returns></returns>
        [HttpGet("sequence")]
        public IActionResult UpdateSequence(int regionId, long sequence)
        {
            application.UpdateGuestSequence(regionId, sequence);
            return SuccessResult();
        }

        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="pageModel"></param>
        /// <returns></returns>
        [HttpPost("list")]
        public IActionResult List(PageModel<OpenCityQuery> pageModel) => SuccessResult(application.List(pageModel));

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpDelete("business/{id}")]
        public IActionResult Deletebusiness(int id)
        {
             application.Deletebusiness(id);
            return SuccessResult();
        }

        /// <summary>
        /// 获取i详情
        /// </summary>
        /// <param name="regionId"></param>
        /// <returns></returns>
        [HttpGet("hot/{regionId}")]
        public IActionResult UpdateHot(int regionId, bool hot)
        {
            application.UpdateHot(regionId, hot);
            return SuccessResult();
        }

        /// <summary>
        /// 城市商业圈
        /// </summary>
        /// <param name="regionId"></param>
        /// <returns></returns>
        [HttpGet("business/list")]
        public IActionResult GetListByRegionId(int regionId) => SuccessResult(application.GetListByRegionId(regionId));

    }
}
